package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;
import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.entity.ShareDictEntity3;
import com.sgb.knowledgeshare.view.activity.ShareUserVideoInfoActivity;
import com.sgb.knowledgeshare.view.activity.VideoReportActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MToast;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by fq on 2020/9/24 0024
 * Description： 分享-举报
 */
public class VideoReportModel  extends ViewModel {
    VideoReportActivity videoreportactivity;
    public void setActivity(VideoReportActivity VideoReportActivity) {
        videoreportactivity = VideoReportActivity;
    }
    //获取举报类型接口
    public void getReportType() {
        DialogHelper.showProgressDialog(videoreportactivity, null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        ShareConfig.getInstance().getApi().getReportType().enqueue(new ICallBack<BaseEntity<List<ShareDictEntity3>>>() {
            @Override
            public void onSuccess(BaseEntity<List<ShareDictEntity3>> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    videoreportactivity.setReportType(data.getData());
                }
            }
        });
    }

//    举报当前视频接口
    public void getReport(String videoid, String key, String reason) {
        Map  map = new HashMap();
        map.put("videoId",videoid);
        map.put("type",key);
        map.put("reason",reason);
        DialogHelper.showProgressDialog(videoreportactivity, null, "提交数据中...", 0, false, null).setCanceledOnTouchOutside(false);
        ShareConfig.getInstance().getApi().getReport(map).enqueue(new ICallBack<BaseEntity>() {
            @Override
            public void onSuccess(BaseEntity data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    MToast.showLongToast(videoreportactivity,"举报成功");
                    videoreportactivity.finish();
                }
            }
        });
    }
}
